<%--
    Document   : registerUser
    Created on : Jul 14, 2011, 5:31:57 PM
    Author     : northpole
--%>

<%@page import="user.User"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
   "http://www.w3.org/TR/html4/loose.dtd">

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
        
        <%User userInfo = (User) session.getAttribute("userInfo");

               if(request.getParameter("name")!=null &&request.getParameter("name").length()>2)
            userInfo.setName(request.getParameter("name"));

        if(request.getParameter("surname")!=null&& request.getParameter("surname").length()>2)
            userInfo.setSurname(request.getParameter("surname"));

        if(request.getParameter("interests")!=null&& request.getParameter("interests").length()>2)
            userInfo.setInterests(request.getParameter("interests"));


        if(request.getParameter("dateOfBirth")!=null&& request.getParameter("dateOfBirth").length()>2)
            userInfo.setDateOfBirth(request.getParameter("dateOfBirth"));

        if(request.getParameter("welcomeText")!=null&& request.getParameter("welcomeText").length()>2)
            userInfo.setWelcomeText(request.getParameter("welcomeText"));

        String x="koko";
        if(userInfo!=null)
        x=userInfo.updateInfo();
        if(x ==null)
            {out.write("X is Null!!!");}
        String redirectURL ="register.jsp?name="+request.getParameter("name")
                +"&surname="+request.getParameter("surname")
                +"&interests="+request.getParameter("interests")
                +"&dateOfBirth="+request.getParameter("dateOfBirth")
                +"&welcomeText="+request.getParameter("welcomeText")
                +"&password="+request.getParameter("password");
        String newUrl=null;
        if(x!=null && x.equals("OK"))
        {boolean athenticate=true;
         newUrl="index.jsp?username="+session.getAttribute("username")+"&password="+
                 session.getAttribute("password")+"&Submit=Submit&athenticate=true";
        session.setAttribute("name",request.getParameter("name") );
 session.setAttribute("surname",request.getParameter("surname") );
 session.setAttribute("interests",request.getParameter("interests") );
 session.setAttribute("dateOfBirth",request.getParameter("dateOfBirth") );
 session.setAttribute("welcomeText",request.getParameter("welcomeText") );
}
        else
            out.write("<h1>"+x+"</h1>");
       out.write(newUrl);
       out.write("</br>"+x+"</br>");
       out.write(redirectURL);
       out.write("</br>"+request.getParameter("username"));
         response.sendRedirect(newUrl);
   %>
    </head>
    <body>

    </body>
</html>
